package com.focus.xyz.core.common.generator;/*
package com.ai.veriscrm.aitools.base.rule;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.activemq.util.ByteArrayInputStream;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import com.ai.appframe2.common.AIException;
import com.ai.appframe2.service.ServiceFactory;
import com.ai.veriscrm.aitools.abo.bo.BOInterResultBean;
import com.ai.veriscrm.aitools.abo.ivalues.IBOInterResultValue;
import com.ai.veriscrm.aitools.abo.ivalues.IBOInterTaskEnvValue;
import com.ai.veriscrm.aitools.base.InterConstants;
import com.ai.veriscrm.aitools.base.driver.DriverFactory;
import com.ai.veriscrm.aitools.base.driver.interfaces.IDriverSV;
import com.ai.veriscrm.aitools.base.utils.ResourceUtil;
import com.ai.veriscrm.aitools.service.interfaces.ISysConfigSV;
import com.ailk.common.config.GlobalCfg;

public class Validator {
	private static final transient Logger log = Logger.getLogger(Validator.class);

	*/
/**
	 * 新增、更新和删除接口的验证
	 * @param sqls
	 * @param envId
	 * @return
	 *//*

	public Map validateByCUD(String sqls,String envId){
		boolean flag = false;
		Map ruleMap = new HashMap();
		IDriverSV driver = null;
		Connection conn = null;
		if(StringUtils.isNotBlank(sqls)){
			ISysConfigSV sv = (ISysConfigSV)ServiceFactory.getService(ISysConfigSV.class);
			try {
				IBOInterTaskEnvValue value = sv.getTaskEnvById(envId);
				if(null!=value){
					String dbType = value.getDbType();
					//根据dbType获取数据库驱动,为空则默认为MySQL
					driver = DriverFactory.getDriver(dbType);
					conn = driver.getConnection(value);
					BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(sqls.getBytes()),"UTF-8"));
					Map aParameterList = new HashMap();
					String sqlLine = null;
					int lineNo = 0;
					RULEOUT:while((sqlLine = reader.readLine())!=null){
						lineNo = lineNo+1;
						if(StringUtils.isNotBlank(sqlLine)){
							//判断是否包含注释"--"行注释
							if(sqlLine.startsWith("--")){
								continue;
							}
							//判断是否包含注释"//"行注释
							if(sqlLine.startsWith("//")){
								continue;
							}
							//判断是否包含"*/
/**//*
"行注释
							if(sqlLine.startsWith("*/
/*")&&sqlLine.endsWith("*//*
")){
								continue;
							}
							//判断是否包含"*/
/**//*
"块注释
							if(sqlLine.startsWith("*/
/*")&&!sqlLine.endsWith("*//*
")){
								while((sqlLine = reader.readLine())!=null){
									lineNo = lineNo+1;
									if(sqlLine.endsWith("*//*
")){
										break;
									}
								}
							}else{
								//执行规则，支持一行多条规则
								String[] sql = sqlLine.split(";");
								for(int i=0;i<sql.length;i++){
									if(StringUtils.isNotBlank(sql[i])){
										//取得sql中的sql变量名
										String[] parameterNames = getParamFromString(sql[i], "#{", "}");
										//如果该条sql中没有sql变量则执行该sql
										if(parameterNames.length==0){
											ResultSet rs = driver.executeQuery2(conn, sql[i]);
											//将查询得到的字段除第一个flag字段外，全部放到Map中
											flag = setParams(rs,aParameterList);
											if(!flag){
												//如果flag为false,则跳出循环，其他sql不再执行。
												ruleMap.put("flag", flag);
												ruleMap.put("message", "第"+lineNo+"行的第"+(i+1)+"个规则验证不通过。");
												break RULEOUT;
											}else{
												ruleMap.put("flag", flag);
												ruleMap.put("message", "第"+lineNo+"行的第"+(i+1)+"个规则验证通过。");
											}
										}else{
											//如果sql中有变量则替换sql变量后再执行
											for(String pName:parameterNames){
												if(StringUtils.isNotBlank(pName)){
													String[] str = pName.split("@");
													String param = (String)aParameterList.get(str[0].toUpperCase());
													String newParam = transParamString(param,",");
													if(str.length==2){
														//如果变量是字符型的，则为变量值加上单引号，其他暂时都不加单引号
														if(InterConstants.S_JDBC_TYPE_VARCHAR.equals(str[1].toUpperCase())){
															sql[i] = replaceParamString(sql[i],"#{"+pName+"}",newParam);
														}else{
															sql[i] = replaceParamString(sql[i],"#{"+pName+"}",param);
														}
													}else if(str.length==1){
														sql[i] = replaceParamString(sql[i],"#{"+pName+"}",param);
													}
												}
											}
											//执行转换后的sql规则
											System.out.println(sql[i]);
											ResultSet rs = driver.executeQuery2(conn, sql[i]);
											flag = setParams(rs,aParameterList);
											if(!flag){
												ruleMap.put("flag", flag);
												ruleMap.put("message", "第"+lineNo+"行的第"+(i+1)+"个规则验证不通过。");
												break RULEOUT;
											}else{
												ruleMap.put("flag", flag);
												ruleMap.put("message", "第"+lineNo+"行的第"+(i+1)+"个规则验证通过。");
											}
										}
									}
								}
							}
						}
					}
					//关闭数据库连接
					driver.closeConnection(conn);
				}
			} catch (Exception e) {
				flag = false;
				ruleMap.put("flag", flag);
				ruleMap.put("message", e.getCause()+":"+e.getMessage());
				log.info("验证增改删接口异常："+e);
			} finally{
				if(conn!=null){
					driver.closeConnection(conn);
				}
			}
		}
		return ruleMap;
	}

	public Map validateByCUD1(String rulePath,String envId){
		boolean flag = false;
		Map ruleMap = new HashMap();
		IDriverSV driver = null;
		Connection conn = null;
		if(StringUtils.isNotBlank(envId)&&StringUtils.isNotBlank(rulePath)){
			ISysConfigSV sv = (ISysConfigSV)ServiceFactory.getService(ISysConfigSV.class);
			try {
				IBOInterTaskEnvValue value = sv.getTaskEnvById(envId);
				if(null!=value){
					String dbType = value.getDbType();
					//根据dbType获取数据库驱动,为空则默认为MySQL
					driver = DriverFactory.getDriver(dbType);
					conn = driver.getConnection(value);
					File ruleFile = new File(rulePath);
					if(ruleFile.exists()){
						BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(rulePath),"UTF-8"));
						Map aParameterList = new HashMap();
						String sqlLine = null;
						int lineNo = 0;
						RULEOUT:while((sqlLine = reader.readLine())!=null){
							lineNo = lineNo+1;
							if(StringUtils.isNotBlank(sqlLine)){
								//判断是否包含注释"--"行注释
								if(sqlLine.startsWith("--")){
									continue;
								}
								//判断是否包含注释"//"行注释
								if(sqlLine.startsWith("//")){
									continue;
								}
								//判断是否包含"*/
/**//*
"行注释
								if(sqlLine.startsWith("*/
/*")&&sqlLine.endsWith("*//*
")){
									continue;
								}
								//判断是否包含"*/
/**//*
"块注释
								if(sqlLine.startsWith("*/
/*")&&!sqlLine.endsWith("*//*
")){
									while((sqlLine = reader.readLine())!=null){
										lineNo = lineNo+1;
										if(sqlLine.endsWith("*//*
")){
											break;
										}
									}
								}else{
									//执行规则，支持一行多条规则
									String[] sql = sqlLine.split(";");
									for(int i=0;i<sql.length;i++){
										if(StringUtils.isNotBlank(sql[i])){
											//取得sql中的sql变量名
											String[] parameterNames = getParamFromString(sql[i], "#{", "}");
											//如果该条sql中没有sql变量则执行该sql
											if(parameterNames.length==0){
												ResultSet rs = driver.executeQuery2(conn, sql[i]);
												//将查询得到的字段除第一个flag字段外，全部放到Map中
												flag = setParams(rs,aParameterList);
												if(!flag){
													//如果flag为false,则跳出循环，其他sql不再执行。
													ruleMap.put("flag", flag);
													ruleMap.put("message", "第"+lineNo+"行的第"+(i+1)+"个规则验证不通过。");
													break RULEOUT;
												}else{
													ruleMap.put("flag", flag);
													ruleMap.put("message", "第"+lineNo+"行的第"+(i+1)+"个规则验证通过。");
												}
											}else{
												//如果sql中有变量则替换sql变量后再执行
												for(String pName:parameterNames){
													if(StringUtils.isNotBlank(pName)){
														String[] str = pName.split("@");
														String param = (String)aParameterList.get(str[0].toUpperCase());
														String newParam = transParamString(param,",");
														if(str.length==2){
															//如果变量是字符型的，则为变量值加上单引号，其他暂时都不加单引号
															if(InterConstants.S_JDBC_TYPE_VARCHAR.equals(str[1].toUpperCase())){
																sql[i] = replaceParamString(sql[i],"#{"+pName+"}",newParam);
															}else{
																sql[i] = replaceParamString(sql[i],"#{"+pName+"}",param);
															}
														}else if(str.length==1){
															sql[i] = replaceParamString(sql[i],"#{"+pName+"}",param);
														}
													}
												}
												//执行转换后的sql规则
												System.out.println(sql[i]);
												ResultSet rs = driver.executeQuery2(conn, sql[i]);
												flag = setParams(rs,aParameterList);
												if(!flag){
													ruleMap.put("flag", flag);
													ruleMap.put("message", "第"+lineNo+"行的第"+(i+1)+"个规则验证不通过。");
													break RULEOUT;
												}else{
													ruleMap.put("flag", flag);
													ruleMap.put("message", "第"+lineNo+"行的第"+(i+1)+"个规则验证通过。");
												}
											}
										}
									}
								}
							}
						}
					}
					//关闭数据库连接
					driver.closeConnection(conn);
				}
			} catch (Exception e) {
				flag = false;
				ruleMap.put("flag", flag);
				ruleMap.put("message", e.getCause()+":"+e.getMessage());
				log.info("验证增改删接口异常："+e);
			} finally{
				if(conn!=null){
					driver.closeConnection(conn);
				}
			}
		}
		return ruleMap;
	}

	*/
/**
	 *
	 * @param expect
	 * @param real
	 * @return
	 *//*

	public boolean compareJsonObj(String expect,String real){
		boolean flag = false;
		if(StringUtils.isNotBlank(expect)&&StringUtils.isNotBlank(real)){
			try{
				//JSON对象比较
				JSONObject expectObj = JSONObject.fromObject(expect);
				JSONObject realObj = JSONObject.fromObject(real);
				int expectHashCode = expectObj.hashCode();
				int realHashCode = realObj.hashCode();
				flag = expectHashCode == realHashCode;
			}catch(Exception e){
				//节点值比较
				flag = StringUtils.equals(real,StringUtils.trim(expect));
			}
		}else{
			if(log.isDebugEnabled()){
				log.debug("预期或实际为空。");
			}
			flag = false;
		}
		return flag;
	}

	*/
/**
	 *
	 * @param rulePath
	 * @param envId
	 * @param expect
	 * @param real
	 * @return
	 *//*

	public Map<String, String> validateByQuery(String rulePath,String envId,String expect,String real){
		Map<String, String> ruleMap = new HashMap<String, String>();
		try{
			if(StringUtils.isBlank(real)){
				ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
				ruleMap.put("message", "失败：实际响应报文为空");
			}else{
				if(StringUtils.isBlank(expect)&&StringUtils.isBlank(rulePath)){
					ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
					ruleMap.put("message", "没有指定预期报文或者规则。");
				}else if(StringUtils.isNotBlank(rulePath)){
					String ruleContent = ResourceUtil.loadFileFromPath(rulePath);
					//只有当规则内容不为空时才比对规则。
					if(StringUtils.isNotBlank(ruleContent)){
						Map<String,String> m = queryRuleValidate1(ruleContent,real);
						String flag = m.get(InterConstants._FLAG);
						if(StringUtils.isNotBlank(flag)){
							ruleMap.put("flag", flag);
							ruleMap.put("message", m.get(InterConstants._MESSAGE));
						}
					}else{
						if(StringUtils.isNotBlank(expect)){
							if (compareJsonObj(expect,real)) {
								ruleMap.put("flag", InterConstants.S_CASE_EXEC_SUCCESS);
								ruleMap.put("message", "成功：预期报文与响应报文一致");
							} else {
								ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
								ruleMap.put("message", "失败：预期报文与响应报文不一致");
							}
						}
					}
				}else{
					if(StringUtils.isNotBlank(expect)){
						if (compareJsonObj(expect,real)) {
							ruleMap.put("flag", InterConstants.S_CASE_EXEC_SUCCESS);
							ruleMap.put("message", "成功：预期报文与响应报文一致");
						} else {
							ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
							ruleMap.put("message", "失败：预期报文与响应报文不一致");
						}
					}
				}
			}
		}catch(Exception e){
			ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
			ruleMap.put("message", "失败："+e.getMessage());
			log.info("验证用例规则异常："+e.getMessage());
		}finally{
		}
		return ruleMap;
	}

	*/
/**
	 *
	 * @param ruleContent
	 * @param real
	 * @return
	 *//*

	public boolean queryRuleValidate(String ruleContent,String real){
		boolean flag = false;
		String[] rules = ruleContent.split("##");
		if(rules!=null&&rules.length>0){
			JSONObject realObj = JSONObject.fromObject(real);
			for(String rule:rules){
				String[] str = rule.split("@@");
				if(str!=null&&str.length>0){
					String type = str[0];
					String node = str[1];
					if(InterConstants._QUERY_RULE_CONTAIN.equals(type)){
						String[] kv = node.split("::");
						if(kv!=null&&kv.length>0){
							String k = kv[0];
							String v = kv[1];
							JSONParser parser = JSONParser.getInstance();
							String realV = parser.getKey(realObj, k).toString();
							if(parser.list!=null&&parser.list.size()>0){
								if(parser.list.contains(StringUtils.trim(v))){
									flag = true;
								}else{
									flag = false;
									break;
								}
							}else{
								if(StringUtils.equals(realV,StringUtils.trim(v))){
									flag = true;
								}else{
									flag = false;
									break;
								}
							}
						}
					}
					if(InterConstants._QUERY_RULE_NOT_CONTAIN.equals(type)){
						String[] kv = StringUtils.split(node, "::");
						if(kv!=null&&kv.length>0){
							String k = kv[0];
							String v = kv[1];
							JSONParser parser = JSONParser.getInstance();
							String realV = parser.getKey(realObj, k).toString();
							if(parser.list!=null&&parser.list.size()>0){
								if(parser.list.contains(StringUtils.trim(v))){
									flag = false;
									break;
								}else{
									flag = true;
								}
							}else{
								if(StringUtils.equals(realV,StringUtils.trim(v))){
									flag = false;
									break;
								}else{
									flag = true;
								}
							}
						}
					}
				}
			}
		}
		return flag;
	}

	*/
/**
	 * 返回Map,能够区别出哪条规则验证不通过
	 * @param ruleContent
	 * @param real
	 * @return
	 *//*

	public Map<String,String> queryRuleValidate1(String ruleContent,String real){
		Map<String,String> rtnMap = new HashMap<String,String>();
		String[] rules = ruleContent.split("##");
		if(rules!=null&&rules.length>0){
			JSONObject realObj = JSONObject.fromObject(real);
			for(int i = 0;i <rules.length;i++){
				String[] str = rules[i].split("@@");
				if(str!=null&&str.length>0){
					String type = str[0];
					String node = str[1];
					if(InterConstants._QUERY_RULE_CONTAIN.equals(type)){
						String[] kv = node.split("::");
						if(kv!=null&&kv.length>0){
							String k = kv[0];
							String v = kv[1];
							JSONParser parser = JSONParser.getInstance();
							String realV = parser.getKey(realObj, k).toString();
							if(parser.list!=null&&parser.list.size()>0){
								if(parser.list.contains(StringUtils.trim(v))){
									rtnMap.put(InterConstants._FLAG, InterConstants._SUCCESS);
									rtnMap.put(InterConstants._MESSAGE, "规则验证通过");
								}else{
									rtnMap.put(InterConstants._FLAG, InterConstants._FAIL);
									rtnMap.put(InterConstants._MESSAGE, "第"+(i+1)+"个规则验证不通过.");
									break;
								}
							}else{
//								if(StringUtils.equals(realV,StringUtils.trim(v))){
								if(compareJsonObj(StringUtils.trim(v), realV)){
									rtnMap.put(InterConstants._FLAG, InterConstants._SUCCESS);
									rtnMap.put(InterConstants._MESSAGE, "规则验证通过");
								}else{
									rtnMap.put(InterConstants._FLAG, InterConstants._FAIL);
									rtnMap.put(InterConstants._MESSAGE, "第"+(i+1)+"个规则验证不通过.");
									break;
								}
							}
						}
					}
					if(InterConstants._QUERY_RULE_NOT_CONTAIN.equals(type)){
						String[] kv = StringUtils.split(node, "::");
						if(kv!=null&&kv.length>0){
							String k = kv[0];
							String v = kv[1];
							JSONParser parser = JSONParser.getInstance();
							String realV = parser.getKey(realObj, k).toString();
							if(parser.list!=null&&parser.list.size()>0){
								if(parser.list.contains(StringUtils.trim(v))){
									rtnMap.put(InterConstants._FLAG, InterConstants._FAIL);
									rtnMap.put(InterConstants._MESSAGE, "第"+(i+1)+"个规则验证不通过.");
									break;
								}else{
									rtnMap.put(InterConstants._FLAG, InterConstants._SUCCESS);
									rtnMap.put(InterConstants._MESSAGE, "规则验证通过");
								}
							}else{
								if(StringUtils.equals(realV,StringUtils.trim(v))){
									rtnMap.put(InterConstants._FLAG, InterConstants._FAIL);
									rtnMap.put(InterConstants._MESSAGE, "第"+(i+1)+"个规则验证不通过.");
									break;
								}else{
									rtnMap.put(InterConstants._FLAG, InterConstants._SUCCESS);
									rtnMap.put(InterConstants._MESSAGE, "规则验证通过");
								}
							}
						}
					}
				}
			}
		}
		return rtnMap;
	}

	*/
/**
	 *
	 * @param rulePath
	 * @param envId
	 * @param expect
	 * @param real
	 * @return
	 *//*

	public Map<String, String> validateException(String rulePath,String envId,String expect,String real){
		Map<String, String> ruleMap = new HashMap<String, String>();
		try{
			if(StringUtils.isBlank(real)){
				ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
				ruleMap.put("message", "失败：实际响应报文为空");
			}else{
				if(StringUtils.isBlank(expect)&&StringUtils.isBlank(rulePath)){
					ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
					ruleMap.put("message", "没有指定预期报文或者规则。");
				}else if(StringUtils.isNotBlank(rulePath)){
					String ruleContent = ResourceUtil.loadFileFromPath(rulePath);
					//只有当规则内容不为空时才比对规则。
					if(StringUtils.isNotBlank(ruleContent)){
						Map<String,String> m = queryRuleValidate1(ruleContent,real);
						String flag = m.get(InterConstants._FLAG);
						if(StringUtils.isNotBlank(flag)){
							ruleMap.put("flag", flag);
							ruleMap.put("message", m.get(InterConstants._MESSAGE));
						}
					}else{
						if(StringUtils.isNotBlank(expect)){
							if (compareJsonObj(expect,real)) {
								ruleMap.put("flag", InterConstants.S_CASE_EXEC_SUCCESS);
								ruleMap.put("message", "成功：预期报文与响应报文一致");
							} else {
								ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
								ruleMap.put("message", "失败：预期报文与响应报文不一致");
							}
						}
					}
				}else{
					if(StringUtils.isNotBlank(expect)){
						if (compareJsonObj(expect,real)) {
							ruleMap.put("flag", InterConstants.S_CASE_EXEC_SUCCESS);
							ruleMap.put("message", "成功：预期报文与响应报文一致");
						} else {
							ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
							ruleMap.put("message", "失败：预期报文与响应报文不一致");
						}
					}
				}
			}
		}catch(Exception e){
			ruleMap.put("flag", InterConstants.S_CASE_EXEC_FAIL);
			ruleMap.put("message", "失败："+e.getMessage());
			log.info("验证用例规则异常："+e.getMessage());
		}finally{
		}
		return ruleMap;
	}

	*/
/**
	 *用例执行完毕先根据实际相应报文验证一下是否执行成功,根据hub_code返回值，1代表HUB返回成功，0代表HUB返回失败。
	 *//*

	public boolean doPreValidate(IBOInterResultValue result,String str){
		boolean flag  = true;
		String code = null;
		String value = null;
		JSONObject hub = null;
		try{
			hub = JSONObject.fromObject(str);
			if(hub.has("hub_code")&&"0".equals(hub.getString("hub_code"))){
				result.setExecFlag(InterConstants.S_CASE_EXEC_FAIL);
				if(hub.has("hub_value")&&StringUtils.isNotBlank(hub.getString("hub_value"))){
					JSONArray hubValues = hub.getJSONArray("hub_value");
					if(hubValues.size()>0){
						JSONObject hubValue = hubValues.getJSONObject(0);
						if(hubValue.has("code")){
							code = hubValue.getString("code");
						}
						if(hubValue.has("value")){
							value = hubValue.getString("value");
						}
						result.setRemarks("HUB返回信息:hub_code=0;"+"Message:"+code+","+value);
					}else{
						result.setRemarks("HUB返回信息:hub_code=0,预校验不通过");
					}
				}else{
					result.setRemarks("HUB返回信息:hub_code=0,预校验不通过");
				}
				flag = false;
			}else{
				//hub_code=1则放过。
				flag = true;
			}
		}catch(Exception e){
			e.printStackTrace();
			flag = true;
		}
		return flag;
	}


	*/
/**
	 *
	 * @param aSourceString
	 * @param aStartStr
	 * @param aEndStr
	 * @return
	 *//*

	public String[] getParamFromString(String aSourceString, String aStartStr,
									   String aEndStr) {
		aSourceString = aSourceString + aEndStr;
		String strSource = aSourceString;
		ArrayList strKey = new ArrayList();
		int iStartIndex = strSource.indexOf(aStartStr);
		int iStartLength = aStartStr.length();
		int iEndLength = aEndStr.length();
		String strTemp = "";
		strTemp = strSource.substring(iStartIndex + iStartLength,
				strSource.length());
		int iEndIndex = strTemp.indexOf(aEndStr)
				+ strSource.substring(0, iStartIndex + iStartLength).length();
		if (iEndIndex == iStartIndex) {
			if (!strTemp.startsWith("="))
				strKey.add(strTemp);
		}
		while ((iStartIndex != -1) && (iEndIndex != -1)
				&& (iStartIndex < iEndIndex)) {
			strTemp = strSource
					.substring(iStartIndex + iStartLength, iEndIndex);
			if (!strTemp.startsWith("="))
				strKey.add(strTemp);
			strSource = strSource.substring(iEndIndex + iEndLength,
					strSource.length());
			iStartIndex = strSource.indexOf(aStartStr);
			strTemp = strSource.substring(iStartIndex + iStartLength,
					strSource.length());
			iEndIndex = strTemp.indexOf(aEndStr)
					+ strSource.substring(0, iStartIndex + iStartLength)
					.length();
		}
		return (String[]) strKey.toArray(new String[0]);
	}

	*/
/**
	 * 设置sql变量的值到Map中
	 * @param rs
	 * @param aParameterList
	 * @return
	 * @throws SQLException
	 *//*

	public boolean setParams(ResultSet rs, Map aParameterList)
			throws SQLException {
		boolean flag = false;
		if (null != rs) {
			while (rs.next()) {
				String f = rs.getString(1);
				if (StringUtils.isNotBlank(f) && "true".equals(f)) {
					flag = true;
					ResultSetMetaData rsmd = rs.getMetaData();
					for (int i = 2; i <= rsmd.getColumnCount(); i++) {
						Object temp = null;
						temp = aParameterList.get(rsmd.getColumnLabel(i));
						if (null != temp) {
							aParameterList.put(StringUtils.upperCase(rsmd.getColumnLabel(i)), temp + "," + rs.getString(i));
						} else {
							aParameterList.put(StringUtils.upperCase(rsmd.getColumnLabel(i)),rs.getString(i));
						}
						*/
/*if(InterConstants.S_DB_TYPE_MYSQL.equals(dbType)){
							temp = aParameterList.get(rsmd.getColumnLabel(i));
							if (null != temp) {
								aParameterList.put(rsmd.getColumnLabel(i), temp + "," + rs.getString(i));
							} else {
								aParameterList.put(rsmd.getColumnLabel(i),rs.getString(i));
							}
						}else if(InterConstants.S_DB_TYPE_ORACLE.equals(dbType)){
							temp = aParameterList.get(rsmd.getColumnName(i));
							if (null != temp) {
								aParameterList.put(rsmd.getColumnName(i), temp + "," + rs.getString(i));
							} else {
								aParameterList.put(rsmd.getColumnName(i),rs.getString(i));
							}
						}*//*

					}
				} else {
					flag = false;
				}
			}
		} else {
			flag = false;
		}
		return flag;
	}

	*/
/**
	 * 将sql中的变量名替换为变量值
	 * @param source
	 * @param s1
	 * @param s2
	 * @return
	 *//*

	public static String replaceParamString(String source, String s1, String s2) {
		int index = source.indexOf(s1);
		if (index == 0)
			return s2 + source.substring(s1.length());
		if (index > 0){
			return source.substring(0, index) + s2 + source.substring(index + s1.length());
		}
		return source;
	}

	public static String replaceParamString(String source, String[] l, String aCode, String aStartStr, String aEndStr) {
		for (int i = 0; i < l.length; i++) {
			source = replaceParamString(source, aStartStr + l[i] + aEndStr, aCode);
		}
		return source;
	}

	*/
/**
	 * 将变量加单引号
	 * @param source
	 * @param aCode
	 * @return
	 *//*

	public static String transParamString(String source,String aCode){
		String[] temp = source.split(aCode);
		String newStr ="";
		for(String s : temp){
			newStr = newStr + "'" + s + "',";
		}
		return newStr.substring(0,newStr.lastIndexOf(","));
	}


	public static void main(String[] args){
		*/
/*String sql = "select 'true',inter_set_id as param2,inter_name as param1 from inter_test;"
				+ "SELECT (CASE WHEN COUNT(*)=1 THEN 'true' ELSE 'false' END) flag from inter_test1 where inter_name in ( #{param1@varchar} ) and inter_set_id in ( #{param2} ) group by inter_name;";
//		new Validator().validateByCUD1("C:\\Users\\Administrator\\Desktop\\test2.sql","10000010");
		new Validator().validateByCUD1("C:\\Users\\Administrator\\Desktop\\test1.sql", "88888888");
//		String json ="{\"hub_code\":\"0\",\"hub_value\":\"\",\"data\":\"\",\"code\":\"\",\"value\":\"\"}";
//		try {
//			IBOInterResultValue bo = new BOInterResultBean();
//			new Validator().doPreValidate(bo, json);
//		} catch (AIException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
*//*

		String rulePrefix = GlobalCfg.getProperty(InterConstants.RULES_DIR);
		String rulePath = rulePrefix + "allocateOrderResource_10000123.rule";
		Validator v = new Validator();
		String real = "{\"data\":{\"accessNo\":9900660,\"createDate\":\"\",\"createOpId\":0,\"createOrgId\":0,\"dbUpdate\":true,\"doneCode\":0,\"doneDate\":\"\",\"effectiveDate\":\"\",\"expireDate\":\"\",\"firstActiveTime\":\"\",\"opId\":0,\"orgId\":0,\"password\":\"\",\"productLine\":{\"createDate\":\"\",\"createOpId\":0,\"createOrgId\":0,\"dbUpdate\":true,\"description\":\"\",\"doneCode\":0,\"doneDate\":\"\",\"effectiveDate\":\"\",\"expireDate\":\"\",\"offeringProdLineRelList\":[{\"testId\":\"123\"},{\"testId\":\"234\"}],\"opId\":0,\"orgId\":0,\"prodLineCode\":\"\",\"prodLineId\":9900660,\"prodLineName\":\"\",\"productLineSpecCharList\":[],\"productLineSpecRelaList\":[],\"refrash\":false,\"regionId\":\"\",\"state\":\"\"},\"productList\":[{\"createDate\":\"\",\"createOpId\":0,\"createOrgId\":0,\"dbUpdate\":true,\"doneCode\":0,\"doneDate\":\"\",\"effectiveDate\":\"\",\"expireDate\":\"\",\"offerInstProductAssocList\":[],\"opId\":0,\"orgId\":0,\"proPriplAssocList\":[],\"proProleAssocList\":[],\"prodId\":9900660,\"prodSpecType\":\"\",\"productAccountAssociationList\":[],\"productAssociationList\":[],\"productCharList\":[],\"productName\":\"\",\"productResourceInsAssociationList\":[],\"productSpecification\":null,\"productStsReasonList\":[],\"refrash\":false,\"regionId\":\"\",\"serviceList\":[],\"state\":\"1\",\"status\":\"\",\"subscriber\":null},{\"createDate\":\"\",\"createOpId\":0,\"createOrgId\":0,\"dbUpdate\":true,\"doneCode\":0,\"doneDate\":\"\",\"effectiveDate\":\"\",\"expireDate\":\"\",\"offerInstProductAssocList\":[],\"opId\":0,\"orgId\":0,\"proPriplAssocList\":[],\"proProleAssocList\":[],\"prodId\":9900661,\"prodSpecType\":\"\",\"productAccountAssociationList\":[],\"productAssociationList\":[],\"productCharList\":[],\"productName\":\"\",\"productResourceInsAssociationList\":[],\"productSpecification\":null,\"productStsReasonList\":[],\"refrash\":false,\"regionId\":\"\",\"serviceList\":[],\"state\":\"1\",\"status\":\"\",\"subscriber\":null}],\"refrash\":false,\"regionId\":\"\",\"state\":\"1\",\"subsSpecialList\":[{\"cancelEvalDate\":\"\",\"cancelEvalReason\":\"\",\"createDate\":\"\",\"createOpId\":0,\"createOrgId\":0,\"dbUpdate\":true,\"doneCode\":0,\"doneDate\":\"\",\"effectiveDate\":\"\",\"evalDate\":\"\",\"evalReason\":\"\",\"expireDate\":\"\",\"opId\":0,\"orgId\":0,\"refrash\":false,\"regionId\":\"\",\"specialListId\":9900660,\"specialListSrc\":\"\",\"specialListType\":\"1\",\"state\":\"1\",\"subscriber\":null},{\"cancelEvalDate\":\"\",\"cancelEvalReason\":\"\",\"createDate\":\"\",\"createOpId\":0,\"createOrgId\":0,\"dbUpdate\":true,\"doneCode\":0,\"doneDate\":\"\",\"effectiveDate\":\"\",\"evalDate\":\"\",\"evalReason\":\"\",\"expireDate\":\"\",\"opId\":0,\"orgId\":0,\"refrash\":false,\"regionId\":\"\",\"specialListId\":9900661,\"specialListSrc\":\"\",\"specialListType\":\"1\",\"state\":\"1\",\"subscriber\":null}],\"subscriberCharList\":[{\"charValue\":\"\",\"createDate\":\"\",\"createOpId\":0,\"createOrgId\":0,\"dbUpdate\":true,\"doneCode\":0,\"doneDate\":\"\",\"effectiveDate\":\"\",\"expireDate\":\"\",\"opId\":0,\"orgId\":0,\"parentCharId\":0,\"refrash\":false,\"regionId\":\"\",\"specChar\":null,\"specCharValue\":null,\"state\":\"1\",\"subscriber\":null,\"subscriberCharId\":9900660},{\"charValue\":\"\",\"createDate\":\"\",\"createOpId\":0,\"createOrgId\":0,\"dbUpdate\":true,\"doneCode\":0,\"doneDate\":\"\",\"effectiveDate\":\"\",\"expireDate\":\"\",\"opId\":0,\"orgId\":0,\"parentCharId\":0,\"refrash\":false,\"regionId\":\"\",\"specChar\":null,\"specCharValue\":null,\"state\":\"1\",\"subscriber\":null,\"subscriberCharId\":9900661}],\"subscriberId\":9900660,\"subscriberName\":\"\"},\"hub_code\":1,\"hub_value\":[{\"code\":\"CRM-000000\",\"value\":\"\"}],\"code\":\"\",\"value\":\"\"}";
		System.out.println(v.validateByQuery(rulePath, null, null, real));;


	}




}
*/
